package com.wangsd.web.utils;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class Validation {
    public static boolean permissionValidate(HttpServletRequest request) {
        HttpSession session = null;
        for (Cookie cookie : request.getCookies()) {
//            if ("user".equals(cookie.getName())) {
//                HttpSession session = request.getSession();
//            }
            if ("user".equals(cookie.getName()) && (session = request.getSession()) != null && session.getAttribute(cookie.getValue()) != null) {
                return true;
            }
        }
        return false;
    }

    public static boolean isNotNull(Object obj) {
        if (obj == null) return false;
        return !"".equals(obj);
    }
}
